<%--
  Created by IntelliJ IDEA.
  User: 我的大名叫陆健伟
  Date: 2016/2/23
  Time: 9:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page pageEncoding="UTF-8" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>我的办件</title>
    <link rel="stylesheet" href="<c:url value='/resource/wechat/css/frozen.css'></c:url>">
    <link rel="stylesheet" href="<c:url value='/resource/wechat/css/main.css'></c:url>">
    <style>
        .ui-list-pure a{color: #000;}
        .sslk_more {
            width: 98%;
            float: left;
            margin-left: 1%;
            height: 35px;
            line-height: 35px;
            color: #fff;
            text-align: center;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 3px;
            clear: both;
            margin-top: 15px;
            margin-bottom: 15px;
            font-family: "微软雅黑", "黑体", "宋体";
            font-size: 1.0rem;
        }
        .sslk_more a {
            color: #fff;
            text-decoration: none;
        }
        #pr_list_foot {
            margin: 0;
            padding: 0;
            height: 3rem;
            line-height: 3rem;
            width: 100%;
            border: none;
            text-align: center;
            -webkit-font-smoothing: antialiased;
            font-size: 0.95rem;
            color: #aba0a0;
            display: none;
        }
        #pr_list_foot a {
            display: block;
            height: 3rem;
            width: 7.5rem;
            margin: 0 auto;
            padding: 0;
            text-align: center;
            font-weight: normal;
            text-decoration: none;
            color: #aba0a0;
        }
    </style>
</head>
<body class="body_bg" ontouchstart>
<header class="ui-header ui-header-positive ui-border-b">
    <i class="ui-icon-return" onclick="history.back()"></i>
    <h1>我的办件</h1>
    <%--<div class="admin_sx"><a href="#" id="sx_but">筛选</a></div>--%>
</header>
<section class="ui-container">
    <section id="tab">
        <div class="demo-item">
            <div class="demo-block">
                <div class="ui-tab">
                    <ul class="ui-tab-nav ui-border-b">
                        <li class="current">待处理</li>
                        <li>处理中</li>
                        <li>已办结</li>
                    </ul>
                    <ul class="ui-tab-content" style="width:300%">
                        <li>
                            <ul class="ui-list ui-list-pure ui-border-tb" id="ul0">
                            </ul>
                        </li>
                        <li>
                            <ul class="ui-list ui-list-pure ui-border-tb" id="ul1">
                            </ul>
                        </li>
                        <li>
                            <ul class="ui-list ui-list-pure ui-border-tb" id="ul2">
                            </ul>

                        </li>


                    </ul>
                </div>
                <input type="hidden" value="${member.guid}" id="loginId">
            </div>
            <script class="demo-script">
            </script>
        </div>
        <div id="pr_list_foot"><a class="foot_icon" onclick="more(this);" href="javascript:void(0)" id="moreButton">加载更多</a></div>
    </section>
    <!--弹出框-->
    <div class="ui-dialog">
        <div class="ui-dialog-cnt">
            <header class="ui-dialog-hd ui-border-b">
                <h3>筛选条件</h3>
                <i class="ui-dialog-close"></i>
            </header>
            <div class="ui-dialog-bd">

                <div> 案件名称：<input type="text" style="width: 150px;" id="keywords" /></div>

                <div><span style="float: left; position: relative; top: 25px; ">申报时间：</span><input id="startTime" type="date" placeholder="开始时间" style="width: 140px; height: 30px; line-height: 30px; margin-left: 80px; text-indent: 5px;float: left; display: inline"/></div>
                <div style="margin-top: 15px;"><input id="endTime" type="date"  placeholder="结束时间"   style="width: 140px;  height: 30px; line-height: 30px; text-indent: 5px; margin-left: 80px;"/></div>
            </div>
            <div class="ui-dialog-ft">
                <button type="button" class="qx-btn">取消</button><!--data-role="button"-->
                <button type="button" id="choose">筛选</button>
            </div>
        </div>
    </div>
</section>
</body>
<script src="<c:url value='/resource/wechat/js/zepto.min.js'/>"></script>
<script src="<c:url value='/resource/wechat/js/frozen.js'/> "></script>
<script class="demo-script">

    var startTime = "";
    var endTime = "";
    var keywords = "";
    var gotoIndex = 0;
    var currentPage = 0;
    var projectstatus = "1";
    var url = "<c:url value='/api/project/bjnew'/>";



//    $("#choose").on("tap",function(){
//        keywords = $("#keywords").val();
//        startTime = $("#startTime").val() != "" ? new Date($("#startTime").val()+ " 00:00:00") : "";
//        endTime = $("#endTime").val() != "" ? new Date($("#endTime").val()+ " 23:59:59") : "";
//        if(Date.parse(startTime) > Date.parse(endTime)){
//            alert("结束时间必须大于开始时间");
//        }else {
//            getData();
//        }
//    })

    function getData(){
        currentPage = 1;
        switch(gotoIndex){
            case 0:
                projectstatus = "1";
                break;
            case 1:
                projectstatus = "2,3";
                break;
            case 2:
                projectstatus = "9,13,-1";
                break;
            default:
                break;

        }
        $.ajax({
            type : "post",
            url : url,
            data : '{"loginId":"'+$("#loginId").val()+',"pageNum":'+ currentPage+',"projectstatus":"'+projectstatus+'"}',
            contentType: "application/json;charset=utf-8",
            async : false,
            dataType : "json",
            success : function(resp){
                $("#ul"+gotoIndex).html("");
                if(resp&&resp.succ){
                    var _data = resp.data.list;
                    var _html = "";
                    if(_data&&_data.length>0){
                        for(var i= 0;i<_data.length;i++){
                            var _item = _data[i];
                            var _url = "<c:url value='/weixin/transact/details/'/>" + _item.guid ;
                            _html += "<li class='ui-border-t' onclick=gotoTranDetail('"+ _url +"')><h4><a href='javascript:void(0)'>"+ _item.matName +"</a></h4>"+
                                    "<p><span>申报时间</span><span class='date'>"+_item.startDoDate+"</span></p></li>";
                        }
                        $("#ul"+gotoIndex).html(_html);
                    }else {
                        $("#pr_list_foot").css("display", "block");
                        $("#pr_list_foot").html("未查询到结果");
                    }
                    console.log(resp.data.totalPage+"_1___"+resp.data.pageIndex);
                    if(resp.data.totalPage >resp.data.pageIndex ){
                        $("#pr_list_foot").css("display", "block");
                    }
                    else{
                        $("#pr_list_foot").css("display", "none");
                    }
                }
            }
        });
    }


</script>
<script>
    (function() {
        var tab = new fz.Scroll('.ui-tab', {
            role: 'tab',
            autoplay: false,
            interval: 3000
        });
        /* 滑动开始前 */
        tab.on('beforeScrollStart', function(fromIndex, toIndex) {
            console.log(fromIndex, toIndex); // from 为当前页，to 为下一页
            gotoIndex = toIndex;
            getData();
        })
    })();

    $(function(){
        currentPage = 1;
        $.ajax({
            type : "POST",
            url : "<c:url value='/api/project/bjnew'/>",
            data : '{loginId":"'+$("#loginId").val()+',"pageNum":'+ currentPage+ ',"projectstatus":"'+projectstatus+'"}',
            contentType: "application/json;charset=utf-8",
            async : false,
            dataType : "json",
            success : function(resp){
                if(resp&&resp.succ){
                    var _data = resp.data.list , _length = _data.length;
                    var _html = "";
                    for(var i= 0;i<_length;i++){
                        var _item = _data[i];
                        var _url = "<c:url value='/weixin/transact/details/'/>" + _item.guid ;
                        _html += "<li class='ui-border-t' onclick=gotoTranDetail('"+ _url +"')><h4><a href='javascript:void(0)'>"+ _item.matName +"</a></h4>"+
                        "<p><span>申报时间</span><span class='date'>"+_item.startDoDate+"</span></p></li>";
                    }
                    $("#ul0").html(_html);
                    if(resp.data.totalPage >resp.data.pageIndex){
                        $("#pr_list_foot").css("display", "block");
                       }else{
                        $("#pr_list_foot").css("display", "none");
                    }
                }else {
                    $("#ul"+gotoIndex).html("<div style='text-align: center;height: 50px; line-height: 50px;'>未查询到结果</div>");
                    $("#pr_list_foot").css("display", "none");
                }
            }
        });
    });

    function more(obj){
        $(obj).html("加载中");
        currentPage ++;
        loadMore(currentPage);
    }

    /*$("#more").on("tap",function(){
        $(this).html("加载中");
        currentPage ++;
        loadMore(currentPage);
    })*/

    function loadMore(page){
        if(!page){
            page =1;
        }
        $.ajax({
            url : url,
            type : "post",
            data : '{"loginId":"'+$("#loginId").val()+', "pageNum":'+currentPage+',"projectstatus":"'+projectstatus+'"}',
            timeout : 6000 ,
            dataType : "json",
            contentType: "application/json;charset=utf-8",
            async : false,
            beforeSend:function(){
                $(".sslk_more").html("数据加载中");
            },
            success : function(resp) {
                if(resp&&resp.succ){
                    var _data = resp.data.list , _length = _data.length;
                    var _html = "";
                    for(var i= 0;i<_length;i++){
                        var _item = _data[i];
                        var _url = "<c:url value='/weixin/transact/details/'/>" + _item.guid ;
                        _html += "<li class='ui-border-t' onclick=gotoTranDetail('"+ _url +"')><h4><a href='javascript:void(0)'>"+ _item.matName +"</a></h4>"+
                                "<p><span>申报时间</span><span class='date'>"+_item.startDoDate+"</span></p></li>";
                    }
                    $("#ul"+gotoIndex).append(_html);
                    if(resp.data.totalPage >resp.data.pageIndex){
                        $("#pr_list_foot").css("display", "block");

                    }else{
                        $("#pr_list_foot").css("display", "none");
                    }
                }else {
                    $("#pr_list_foot").css("display", "block");
                    $("#moreButton").html("无更多数据");
                }
            }
        });
    }

    function gotoTranDetail(url){
        window.location.href = url;
    }

</script>
<script>
    $(function(){
        /*
        $("#sx_but").click(function(){
            $(".ui-dialog").dialog("show");
        })
        $(".ui-dialog-close").click(function(){
            $(".ui-dialog").dialog("hide");
        })
        $(".ui-dialog-ft>button").click(function(){
            $(".ui-dialog").dialog("hide");
        })*/

        $("#choose").click(function(e){
            e.stopPropagation();
            keywords = $("#keywords").val();
            startTime = $("#startTime").val() != "" ? $("#startTime").val()  : "";
            endTime = $("#endTime").val() != "" ? $("#endTime").val() : "";
            if(Date.parse(startTime) > Date.parse(endTime)){
                alert("结束时间必须大于开始时间");
            }else {
               getData();
            }
            $(this).parents(".ui-dialog").hide();
        })
        $(".ui-dialog-close,.qx-btn").click(function(e){
            $(this).parents(".ui-dialog").hide();
            e.stopPropagation();
        })
        $("#sx_but").click(function(e){
            $(".ui-dialog").css("display","-webkit-box;");
            e.stopPropagation();
        })

    })
</script>
</html>